/*    */ package com.asiainfo.dacp.stat.olapcheck;
/*    */ 
/*    */ import com.asiainfo.dacp.jdbc.JdbcTemplate;
/*    */ import com.asiainfo.dacp.util.JsonHelper;
/*    */ import java.util.ArrayList;
/*    */ import java.util.HashMap;
/*    */ import java.util.List;
/*    */ import java.util.Map;
/*    */ import org.springframework.stereotype.Service;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ @Service
/*    */ public class OlapCheckService
/*    */ {
/*    */   private Map paraMap;
/*    */   private List paraList;
/*    */   private Map<String, List<Map<String, Object>>> resultMap;
/*    */   private List<Map<String, Object>> memberList;
/*    */   private JdbcTemplate jdbcTemplate;
/*    */   
/*    */   public String olapQuery(String jsonFromWeb)
/*    */   {
/* 25 */     String jsonToWeb = "error";
/* 26 */     JsonHelper jsonHelper = JsonHelper.getInstance();
/* 27 */     Object obj = jsonHelper.read(jsonFromWeb);
/* 28 */     if ((obj != null) && (!obj.toString().equals(""))) {
/* 29 */       if ((obj instanceof Map)) {
/* 30 */         this.paraMap = ((Map)obj);
/* 31 */       } else if ((obj instanceof List)) {
/* 32 */         this.paraList = ((List)obj);
/*    */       }
/* 34 */       if (this.paraMap != null) {
/* 35 */         this.paraList = ((List)this.paraMap.get("paras"));
/*    */       }
/* 37 */       getJsonResultData(this.paraList);
/*    */       
/* 39 */       jsonToWeb = jsonHelper.write(this.resultMap);
/*    */     }
/* 41 */     return jsonToWeb;
/*    */   }
/*    */   
/*    */   public void getJsonResultData(List<Map> list) {
/* 45 */     this.jdbcTemplate = new JdbcTemplate();
/* 46 */     this.resultMap = new HashMap();
/* 47 */     this.memberList = new ArrayList();
/* 48 */     for (Map row : list) {
/* 49 */       String paraname = (String)row.get("paraname");
/* 50 */       String paratype = (String)row.get("paratype");
/* 51 */       String sql = (String)row.get("sql");
/* 52 */       this.memberList.add(getJsonMemberData(paraname, paratype, sql));
/*    */     }
/* 54 */     this.resultMap.put("root", this.memberList);
/*    */   }
/*    */   
/*    */   public Map getJsonMemberData(String paraname, String paratype, String sql) {
/* 58 */     Map memberMap = new HashMap();
/*    */     
/* 60 */     if (paratype.equals("map")) {
/* 61 */       memberMap.put(paraname, this.jdbcTemplate.queryForMap(sql));
/* 62 */     } else if (paratype.equals("array")) {
/* 63 */       memberMap.put(paraname, this.jdbcTemplate.queryForList(sql));
/*    */     }
/* 65 */     return memberMap;
/*    */   }
/*    */   
/*    */   public boolean prepareOlapData(String olapcode, String optime, String comparetime) {
/* 69 */     String sql = " select count(1) from MINDER_OLAPDIM_CHKINFO where olapcode=? and optime=? and comparetime=?";
/*    */     
/* 71 */     this.jdbcTemplate = new JdbcTemplate();
/* 72 */     int size = ((Integer)this.jdbcTemplate.queryForObject(sql, new Object[] { olapcode, optime, comparetime }, Integer.class)).intValue();
/* 73 */     if (size > 0) {
/* 74 */       return true;
/*    */     }
/* 76 */     return false;
/*    */   }
/*    */ }


/* Location:              C:\Users\my\.m2\repository\com\asiainfo\dacp\dacp-dataos\1.0.0\dacp-dataos-1.0.0.jar!\com\asiainfo\dacp\stat\olapcheck\OlapCheckService.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */